/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Wearhouse")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Wearhouse.findAll", query = "SELECT w FROM Wearhouse w"),
    @NamedQuery(name = "Wearhouse.findByWearhouseID", query = "SELECT w FROM Wearhouse w WHERE w.wearhouseID = :wearhouseID"),
    @NamedQuery(name = "Wearhouse.findByWHDesc", query = "SELECT w FROM Wearhouse w WHERE w.wHDesc = :wHDesc"),
    @NamedQuery(name = "Wearhouse.findByWHLoc", query = "SELECT w FROM Wearhouse w WHERE w.wHLoc = :wHLoc"),
    @NamedQuery(name = "Wearhouse.findResaleable", query = "SELECT w FROM Wearhouse w WHERE w.wHResalable = 'true' ORDER BY w.wHDesc ASC")})
public class Wearhouse implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "WearhouseID")
    private Integer wearhouseID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "WHDesc")
    private String wHDesc;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 100)
    @Column(name = "WHLoc")
    private String wHLoc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Resalable")
    private boolean wHResalable;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "whid")
    private Collection<StockCode> stockCodeCollection;

    public Wearhouse() {
    }

    public Wearhouse(Integer wearhouseID) {
        this.wearhouseID = wearhouseID;
    }

    public Wearhouse(Integer wearhouseID, String wHDesc, String wHLoc, boolean wHResalable) {
        this.wearhouseID = wearhouseID;
        this.wHDesc = wHDesc;
        this.wHLoc = wHLoc;
        this.wHResalable = wHResalable;
    }

    public Integer getWearhouseID() {
        return wearhouseID;
    }

    public void setWearhouseID(Integer wearhouseID) {
        this.wearhouseID = wearhouseID;
    }

    public String getWHDesc() {
        return wHDesc;
    }

    public void setWHDesc(String wHDesc) {
        this.wHDesc = wHDesc;
    }

    public String getWHLoc() {
        return wHLoc;
    }

    public void setWHLoc(String wHLoc) {
        this.wHLoc = wHLoc;
    }
    
    public boolean getWHResalable(){
        return wHResalable;
    }
    
    public void setWHResalable(boolean wHResalable){
        this.wHResalable = wHResalable;
    }

    @XmlTransient
    public Collection<StockCode> getStockCodeCollection() {
        return stockCodeCollection;
    }

    public void setStockCodeCollection(Collection<StockCode> stockCodeCollection) {
        this.stockCodeCollection = stockCodeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (wearhouseID != null ? wearhouseID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Wearhouse)) {
            return false;
        }
        Wearhouse other = (Wearhouse) object;
        if ((this.wearhouseID == null && other.wearhouseID != null) || (this.wearhouseID != null && !this.wearhouseID.equals(other.wearhouseID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Wearhouse[ wearhouseID=" + wearhouseID + " ]";
    }
    
}
